//
//  Copyright © 2015年 lanou3g. All rights reserved.
//

#import "ChatViewController.h"
#import <AVOSCloud/AVOSCloud.h>

#import <AVOSCloudIM/AVOSCloudIM.h>
#import "TomAndJerryEpisode.h"
#import "ConversationViewController.h"
@interface ChatViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong)UITableView *tableview;
@end

@implementation ChatViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //单聊
   // TomAndJerryEpisode *jj = [[TomAndJerryEpisode alloc]init];
   // [jj tomSendMessageToJerry];

   // [jj jerryReceiveMessageFromTom];
    
    //[jj tomQueryMessagesWithLimit];
    
    //单聊
   // TomAndJerryEpisode *jj2 = [[TomAndJerryEpisode alloc]init];
    //[jj tomSendMessageToJerry];
    
    //[jj2 jerryReceiveMessageFromTom];
    
    //保存数据
    
    /*
    AVObject *testObject = [AVObject objectWithClassName:@"TestObject"];
    [testObject setObject:@"bar" forKey:@"foo"];
    [testObject save];
    
    AVObject *post = [AVObject objectWithClassName:@"Post"];
    [post setObject:@"我的开发工具" forKey:@"content"];
    [post setObject:@"LeanCloud官方客服" forKey:@"pubUser"];
    [post setObject:[NSNumber numberWithInt:1435541999] forKey:@"pubTimestamp"];
    [post setObject:@"开发工具" forKey:@"tablename"];
    [post save];
     
    
    
    AVObject *testObject2 = [AVObject objectWithClassName:@"lining"];
    [testObject2 setObject:@"lining" forKey:@"name"];
    
    [testObject2 setObject:@"男" forKey:@"gender"];
    [testObject2 save];
    */
    
    
    /*
     
     AVObject *post = [AVObject objectWithClassName:@"Post"];
     post[@"content"] = @"每个 Objective-C 程序员必备的 8 个开发工具";
     post[@"pubUser"] = @"LeanCloud官方客服";
     post[@"pubTimestamp"] = @(1435541999);
     [post save];
     
     
     */
    //检索到数据
    /*
    AVQuery *query = [AVQuery queryWithClassName:@"lining"];
    AVObject *post = [query getObjectWithId:@"565c0f7fddb299ad3907651a"];
    
    //int timestamp = [[post objectForKey:@"pubTimestamp"] intValue];
    NSString *gender = [post objectForKey:@"gender"];
    NSString *name = post[@"name"];
    
    NSString *objectId = post.objectId;
    NSDate *updatedAt = post.updatedAt;
    NSDate *createdAt = post.createdAt;
    
    NSLog(@"%@,%@,%@,%@,%@",gender,name,objectId,updatedAt,createdAt);
    */
    self.tableview = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
    self.tableview.backgroundColor = [UIColor clearColor];
    self.tableview.delegate =self;
    self.tableview.dataSource = self;
    [self.view addSubview:self.tableview];
    
    
    self.view.backgroundColor = [UIColor cyanColor];
    //self.navigationController.title = @"朋友";
    self.navigationItem.title = @"朋友";
    [self.tableview registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 4;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    switch (indexPath.row) {
        case 0:
            cell.textLabel.text = @"我的朋友";
            
            break;
        case 1:
            cell.textLabel.text = @"我的小组";
            
            break;
        case 2:
            cell.textLabel.text = @"附近的人";
            
            break;
        case 3:
            cell.textLabel.text = @"客服";
            
            break;
        default:
            break;
    }
    
    return cell;
    
    
    
    
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    //单聊
    //TomAndJerryEpisode *jj2 = [[TomAndJerryEpisode alloc]init];
    //[jj tomSendMessageToJerry];
    
   // [jj2 jerryReceiveMessageFromTom];
    
    switch (indexPath.row) {
        case 0:
            
            break;
        case 1:
            
            break;
        case 2:
            
            break;
        case 3:
        {
            ConversationViewController * conVC = [[ConversationViewController alloc]init];
            conVC.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:conVC animated:YES];
        
           // [self presentViewController:conVC animated:YES completion:nil];
        }
            
            
            break;
        default:
            break;
    }
    
    
    
}
@end
